# Embedded Rust [[Rust]] is a pretty promising language for bare-metal [[Embedded]] programming. As always, getting a devboard up and running is the most painful part, as compiler error, linker problems, debugger tools are all not so fun. There is a whole book about Embedded Rust: - [[BOOK - Embedded Rust Discovery]], both for [[F3 Discovery]] and [[BBC Microbit]], both [[ARM Cortex-M]] boards. I am working on Embedded Rust with Michael and Asya on the [[IDEA - Rust based Microbit Typewriter]], where we use [[waveshare 4.2 inch e-ink display]] (over SPI) and control a [[PS2 Keyboard - OSDev Wiki]] ## Embedded HAL The [GitHub - rust-embedded/wg: Coordination repository of the embedded devices Working Group](https://github.com/rust-embedded/wg) provides a standard embedded HAL for all embedded Rust projects: - [GitHub - rust-embedded/embedded-hal: A Hardware Abstraction Layer (HAL) for embedded systems](https://github.com/rust-embedded/embedded-hal) ## Embassy project - [Embassy :: Embassy Docs](https://embassy.dev/dev/index.html) > Embassy is a project to make async/await a first-class option for embedded development. ### Embassy-net A networking stack built on top of embassy itself. - [embassy_net - Rust](https://docs.embassy.dev/embassy-net/git/default/index.html) ## Tools Cargo embed is a cargo runner to compile, run and debug embedded programs. It works really well. It can flash, show RTT output, provide a gdb server connection. - [cargo-embed | probe-rs](https://probe.rs/docs/tools/cargo-embed/) probe-run is a cargo runner that can run embedded firmwares (cargo run), displays RTT output, show stacktraces. - [crates.io: Rust Package Registry](https://crates.io/crates/probe-run) In general, [Knurling-rs](https://knurling.ferrous-systems.com) is [[Ferrous Systems]] project to provide better embedded tools: - [GitHub - knurling-rs/flip-link: Adds zero-cost stack overflow protection to your embedded programs](https://github.com/knurling-rs/flip-link) - [GitHub - knurling-rs/defmt: Efficient, deferred formatting for logging on embedded systems](https://github.com/knurling-rs/defmt) - [Introduction - defmt book](https://defmt.ferrous-systems.com) There's a bunch of [[RTOS]] linked from here: - [Are We RTOS Yet? - Are We RTOS Yet?](https://arewertosyet.com/) ## Links Here's a pretty thorough write up on doing embedded development with [[Rust]] with a list of good tips on host/device cross-compilation, unit tests, etc...: - [Testing an embedded application](https://ferrous-systems.com/blog/test-embedded-app/#structuring-the-project-for-host--and-cross-compilation) A bunch of write ups about using [[Rust]] on [[AVR]] - [HShhss | Hoj Senna’s humble heap of stray scribbles](https://hoj-senna.github.io/HShhss/) There is a bunch of starter code to program the [[Daisy Patch]] in [[Embedded Rust]]. - [Rust starter for Daisy Seed - Software Development - Daisy Forums](https://forum.electro-smith.com/t/rust-starter-for-daisy-seed/684) And a BSP layer: - [GitHub - mtthw-meyer/libdaisy-rust: Hardware Abstraction Layer implementation for Daisy boards](https://github.com/mtthw-meyer/libdaisy-rust) Toggling a GPIO pin in an interrupt: - [GPIO Interrupt: Let Me Know When You Need Me | Alone on a Mountaintop](https://lonesometraveler.github.io/2020/04/17/GPIO_interrupt.html) Embedded advanced book: - [Introduction - The Embedded Rust Book](https://docs.rust-embedded.org/book/index.html) ## [[Raspberry Pi]] - [GitHub - embassy-rs/cyw43: Pure-Rust driver for the CYW43439 (WiFi chip used in the Raspberry Pi Pico W)](https://github.com/embassy-rs/cyw43)